﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WgFrame.Net;

public class Player
{
    /// <summary>
    /// 玩家id
    /// </summary>
    public long Id { get; private set; }

    /// <summary>
    /// 玩家名字
    /// </summary>
    public string Name { get; set; }

    /// <summary>
    /// 基本信息
    /// </summary>
    public BaseInfo BaseInfo { get; private set; }

    /// <summary>
    /// 背包道具
    /// </summary>
    public PackItemMgr PackItemMgr { get; private set; }

    /// <summary>
    /// 背包英雄
    /// </summary>
    public PackHeroMgr PackHeroMgr { get; private set; }

    /// <summary>
    /// 背包装备
    /// </summary>
    public PackEquipMgr PackEquipMgr { get; private set; }

    /// <summary>
    /// 上阵英雄
    /// </summary>
    public FightHeroMgr FightHeroMgr { get; private set; }

    /// <summary>
    /// 上阵装备
    /// </summary>
    public FightEquipMgr FightEquipMgr { get; private set; }

    /// <summary>
    /// 战斗属性管理
    /// </summary>
    public FighAttributeMgr FighAttributeMgr { get; private set; }


    public Player(long playerId)
    {
        this.Id = playerId;
        BaseInfo = new BaseInfo();
        PackItemMgr = new PackItemMgr();
        PackHeroMgr = new PackHeroMgr();
        PackEquipMgr = new PackEquipMgr();
        FightHeroMgr = new FightHeroMgr();
        FightEquipMgr = new FightEquipMgr();
        FighAttributeMgr = new FighAttributeMgr();
    }

    public void PlayFight()
    {
        FightItem[] rightTeam = new FightItem[ConfigUtil.FIGHT_MEMBER_COUNT];
        FightItem[] leftTeam = new FightItem[ConfigUtil.FIGHT_MEMBER_COUNT];

        List<Hero> heros = FightHeroMgr.GetAll();
        foreach (Hero hero in heros)
        {
            leftTeam[hero.bzPos-1] = new FightItem(hero); 
        }

        List<Monster> monsters = MonsterMgr.Dict.Values.ToList();
        for(int i=0; i< rightTeam.Length; i++)
        {
            rightTeam[i] = new FightItem(monsters[UnityEngine.Random.Range(0, monsters.Count - 1)]);
        }

        MsgListenerMgr.FireMsg(MsgListenerType.StartFight, rightTeam, leftTeam);
    }
}
